﻿

#ifndef _AbstractGeometryData_H_
#define _AbstractGeometryData_H_

#include "CoreApi.hpp"
#include "AbstractObject.hpp"
#include "AbstractGeometry.hpp"

#include <QList>
#include <QMap>
#include <vtkPoints.h>
#include <vtkPolyData.h>
#include <vtkFeatureEdges.h>
#include <vtkSmartPointer.h>
#include <vtkAppendPolyData.h>
#include <vtkPolyDataNormals.h>

#include <TopoDS_Shape.hxx>


namespace NSCore {


	class COREAPI GeoPoint {
	public:
		GeoPoint(double x = 0.0, double y = 0.0, double z = 0.0) : x(x), y(y), z(z) {}
		~GeoPoint() {};
	private:
		double x;
		double y;
		double z;

	public:
		double X() { return x; };
		double Y() { return y; };
		double Z() { return z; };
		void XYZ(double* pos) { pos[0] = x; pos[1] = y;	pos[2] = z; };
		void setXyz(double _x, double _y, double _z) { x = _x; y = _y;	z = _z; };
		QString toString() { return QString("[%1,%2,%3]").arg(x).arg(y).arg(z); };
		GeoPoint& operator=(const GeoPoint& other) {
			if (this != &other) {
				x = other.x;
				y = other.y;
				z = other.z;
			}
			return *this;
		}
	};

	class COREAPI AbstractGeometryData : public AbstractObject {

	public:
		AbstractGeometryData();
		virtual ~AbstractGeometryData();
		enum GeoType {
			GeoUndef = 0,
			GeoPoint,
			GeoEdge,
			GeoFace,
			GeoSolid,
			GeoMesh 
		};

	public:
		virtual int addGeometryRaw(int id, QList<int>& ids, Sp(vtkPolyData) raw, TopoDS_Shape tp);
		virtual AbstractGeometry* getGeometryRaw(int id);
		virtual void clearGeometryRaw();
		virtual QPair<Sp(vtkPolyData), TopoDS_Shape> getGeometryPart();
		virtual void setGeometryPart(TopoDS_Shape topo);
		virtual Sp(vtkPolyData) getGeometryEdges();
		virtual Sp(vtkPolyData) normal_data(Sp(vtkPolyData) data);
		virtual int getId(int cellid);
		virtual void mapId(int key_id, int value_id);  
		virtual void updateGeometry(TopoDS_Shape tp);
		virtual void setGeoType(GeoType type) { m_geotype = type; };
		virtual const GeoType getGeoType() { return m_geotype; };
		virtual void setGeoPoints(QList<NSCore::GeoPoint>& points);
		virtual void getGeoPoints(QList<NSCore::GeoPoint>& points);
		virtual const QList<NSCore::GeoPoint> getGeoPoints();


	public:
		virtual inline QString className() override { return "AbstractGeometryData"; };
	protected: 
		GeoType m_geotype{ GeoType::GeoUndef };
		QMap<int, int> m_id_map;
		QList<NSCore::AbstractGeometry*> m_geoms;
		Sp(vtkAppendPolyData) m_part {nullptr};
		TopoDS_Shape m_shape;
		//注意类名区分
		QList<NSCore::GeoPoint> m_geopoints;

	private:




	};


}

#endif